home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’97
/
Klingon BG App
/
Source
/
speechUtil.c
< prev
next >
Wrap
Text File
|
1997-06-28
|
3KB
|
189 lines
// Source code for Klingon Clock. Copyright (C) 1996-1997
// Charles H. Hemstreet IV
//
// Started at MacHack 1996
// Completed at MacHack 1997
//
// Best thanks to:
// My wife Regie, son Chad and baby
// Other thanks to Elden Wood and Bob Clark
//
// This code is distributed "as-is" and implies no warranty or guarantee.
#ifndef __SPEECHUTIL__
#include "speechUtil.h"
#endif
OSErr doSuccessSound(void)
{
OSErr myMainErr;
myMainErr = openSndChannel();
assert(myMainErr == noErr);
myMainErr = LoadBufferSounds();
assert(myMainErr == noErr);
// let the user know we were successful!!
myMainErr = doPlayASound(kKaplah, kPriority);
assert(myMainErr == noErr);
waitCloseChannel();
return myMainErr;
}
OSErr speakSentence(short MySndID[], short MySndID1[], short MySndID2[])
{
int loop;
OSErr myErr = noErr;
short soundID;
myErr = openSndChannel();
assert(myErr == noErr);
myErr = doPlayASound(kTime, kPriority);
assert(myErr == noErr);
for (loop = 0; loop < kHoursMinutes; loop++)
{
soundID = MySndID[loop];
myErr = doPlayASound(soundID, kPriority);
assert(myErr == noErr);
soundID = MySndID1[loop];
myErr = doPlayASound(soundID, kPriority);
assert(myErr == noErr);
soundID = MySndID2[loop];
myErr = doPlayASound(soundID, kPriority);
assert(myErr == noErr);
}
waitCloseChannel();
return myErr;
}
OSErr makeSentence(short cur_tick[], short MySndID[], short MySndID1[], short MySndID2[])
{
int loop;
OSErr myErr = noErr;
for (loop = 0; loop < kHoursMinutes; loop++)
{
// if the unit is greater than ten, say ten
// klingon numbers are constructed with ten in the middle
// so that eleven is "one ten and one". Twenty is "two tens"
// Default is null if not greater than 9.
if (cur_tick[loop] > 9)
{
MySndID1[loop] = kTen;
}
else
{
MySndID1[loop] = NULL;
}
// if the unit is greater than ten, then make sure you
// get the correct tens place number
// default is NULL if less than 10
if ((cur_tick[loop] > 9) && (cur_tick[loop] < 20))
{
MySndID[loop] = kOne;
cur_tick[loop] -= 10;
} else if ((cur_tick[loop] > 19) && (cur_tick[loop] < 30))
{
MySndID[loop] = kTwo;
cur_tick[loop] -= 20;
} else if ((cur_tick[loop] > 29) && (cur_tick[loop] < 40))
{
MySndID[loop] = kThree;
cur_tick[loop] -= 30;
} else if ((cur_tick[loop] > 39) && (cur_tick[loop] < 50))
{
cur_tick[loop] -= 40;
MySndID[loop] = kFour;
} else if ((cur_tick[loop] > 49) && (cur_tick[loop] <= 59))
{
cur_tick[loop] -= 50;
MySndID[loop] = kFive;
} else
{
MySndID[loop] = NULL;
}
// now take care of the ones place. We will always get a ones place
//
switch (cur_tick[loop])
{
case 0:
{
if (MySndID[loop] == NULL)
MySndID2[loop] = kZero;
else
MySndID2[loop] = NULL;
break;
}
case 1:
{
MySndID2[loop] = kOne;
break;
}
case 2:
{
MySndID2[loop] = kTwo;
break;
}
case 3:
{
MySndID2[loop] = kThree;
break;
}
case 4:
{
MySndID2[loop] = kFour;
break;
}
case 5:
{
MySndID2[loop] = kFive;
break;
}
case 6:
{
MySndID2[loop] = kSix;
break;
}
case 7:
{
MySndID2[loop] = kSeven;
break;
}
case 8:
{
MySndID2[loop] = kEight;
break;
}
case 9:
{
MySndID2[loop] = kNine;
break;
}
default:
break;
}
}
return myErr;
}